{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">消息列表</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('notice/add')}"
                   data-auth-edit="{:$auth->check('notice/edit')}"
                   data-auth-delete="{:$auth->check('notice/del')}"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/html" id="picTpl">
    <img style="max-width:80px; max-height:30px;" src="{{d.icon_img}}" data-image="{{d.name}}">
</script>


<script type="text/html" id="barTool">

    <a class="layui-btn layui-btn-xs  layui-btn-normal" data-open='{:url("sendList")}?id={{ d.id }}' data-title="消息回复"
       data-full="true">消息回复</a>

</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="显示|隐藏" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
        };

        table.render({
            init: init,
            toolbar: ['refresh'],
            url: '{:url("index")}',
            search: true,
            cols: [
                [
                    //id 发送账号信息 角色信息 内容 发送时间 关联通知 //编辑 消息记录
                    {field: 'id', width:'10%', align: "center", title: 'ID'},
                    {field: 'obj_info', width: '22%', align: "center", title: '账号信息', search:false},

                    {
                        field: 'role', width: '8%', align: "center", title: '角色类型', templet: function (d) {
                            if (d.role == 1) {
                                return '<span style="color: #00a0e9">用户</span>';
                            }  if (d.role == 2) {
                                return '<span style="color: #00B83F">商户</span>';
                            } else {
                                return '<span style="color: green">平台</span>';
                            }
                        }, selectList: {1: '用户', 2: '商户'}
                    },

                    {field: 'content', width: '20%', align: "center", title: '内容', search:false},

                    {field: 'notice', width: '10%', align: "center", title: '关联通知', search:false},

                    {field: 'create_time', width:'15%', align: "center", title: '发送时间', search:false},

                    {fixed: 'right', width: '20%', align: "center", title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });

        yznTable.bindevent();
    });
</script>
{/block}